package com.snoob.springcloudalibaba.base;

import com.snoob.springcloudalibaba.enums.SysStateEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @描述 自定义异常类（spring遇到RuntimeException异常会进行事务回滚）
 * @作者: lixing lixing_java@163.com
 * @日期 2019/6/29 22:48
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BaseException extends RuntimeException {
    /**
     * 异常码
     */
    private int code;
    /**
     * 异常信息
     */
    private String message;

    public BaseException() {}

    public BaseException(String message) {
        super( message );
        this.code = SysStateEnum.RESPONSE_STATUS_FALSE.getValue();
        this.message = message;
    }

    public BaseException(int code, String message) {
        super( message );
        this.code = code;
        this.message = message;
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
        this.code = SysStateEnum.RESPONSE_STATUS_FALSE.getValue();
        this.message = message;
    }

    public BaseException(int code, String message, Throwable cause) {
        super(message, cause);
        this.code = code;
        this.message = message;
    }
}
